<?php

namespace app\common\model;

class User extends Base
{
    // 数据表名称
    protected $name = 'users';

    protected $pk = 'id';


    /**
     * 格式化列表数据
     */
    public static function formatDatas($list, $params = '')
    {
        foreach ($list as &$item) {
            $item = self::formatItem($item, $params);
        }

        return $list;
    }

    /**
     * 格式化单个数据
     */
    public static function formatItem($item, $params = '')
    {
        if (!$item) {
            return '';
        }

        if ($item['avatar']) {
            $item['full_avatar'] = full_file_url($item['avatar']);
        } else {
            /*if ($item['sex'] == 1) {
                $item['full_avatar'] = asset(config('path.static_path') . 'img/default_male.png');
            } else {
                $item['full_avatar'] = asset(config('path.static_path') . 'img/default_female.png');
            }*/
            $item['full_avatar'] = letter_avatar($item['name']);
        }

        return $item;
    }
}